package com.wk.controller.student;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wk.pojo.*;
import com.wk.service.Courseservice;
import com.wk.service.Itemservice;
import com.wk.utils.PaginationConstant;
import com.wk.utils.responseresult;
import org.apache.poi.xwpf.usermodel.ParagraphAlignment;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.*;

/**
 * @program: thesis
 * @description: 用于设置用户试题库的控制类
 * @author: 王侃
 * @create: 2020-02-23 09:32
 **/
@Controller

public class Stuitemcontroller {

    @Autowired
    Itemservice itemservice;

    @Autowired
    Courseservice courseservice;

    //返回课程的类型
    @ModelAttribute("coursetypes")
    public List<Coursetype> coursetypes()
    {
        List<Coursetype> coursetypes=courseservice.selectbyalltype();
        return coursetypes;
    }

    //跳转到分题型显示的习题中
    @RequestMapping("/item/overview")
    public String item_overview(Model model)
    {
        List<Item_type> types=itemservice.selectbyitemtype();
        model.addAttribute("types",types);

        return "student/item/item_overview";
    }

    //跳转到分章节显示的习题中
    @RequestMapping("/item/chapter/overview")
    public String item_overview_chapter(Model model)
    {
        List<Coursetype> types=itemservice.selectbyallcoursetype();
        model.addAttribute("types",types);
        return "student/item/item_overview_chapter";
    }

    //跳转到分章节习题的练习模式
    @RequestMapping("/item/chapter/test/{id}")
    public String item_chapter_test(@PathVariable("id") Integer id,Model model)
    {
        List<Course_exam> tests=itemservice.selectbychapterexam(id);
        model.addAttribute("tests",tests);
        model.addAttribute("chapter_id",id);
        return "student/item/item_test_chapter";
    }

    //开始习题库分题型练习模式
    @RequestMapping("/item/test/{id}")
    public String item_test(@PathVariable("id") Integer id,Model model)
    {
        //通过type_id查找出对应的试题
        List<Map<String,Object>> tests=itemservice.selectbyitemexam(id);
        model.addAttribute("tests",tests);

        model.addAttribute("typeid",id);
        return "student/item/item_test";
    }

    //开始习题库分章节考试模式
    @RequestMapping("/item/exam/chapter/{id}")
    public String item_exam_chapter(@PathVariable("id") Integer id,Model model)
    {
        List<Course_exam> tests=itemservice.selectbychapterexam(id);
        model.addAttribute("contents",tests);
        return "student/item/item_exam_chapter";
    }

    //开始习题库分题型考试模式
    @RequestMapping("/item/exam/{id}")
    public String item_exam(@PathVariable("id") Integer id,Model model)
    {

        //通过type_id查找出对应的试题
        List<Map<String,Object>> tests=itemservice.selectbyitemexam(id);
        model.addAttribute("tests",tests);

        model.addAttribute("typeid",id);
        return "student/item/item_exam";
    }

    //提交单选双选习题库
    @RequestMapping("/item/exam/submit")
    public String test_submit(@RequestParam Map<String,String> map, Model model)
    {
        Set<String> set=map.keySet();//用来获取题目的id号,所以id号为String
        Iterator<String> iterator=set.iterator();//必需的
        Integer falsenumber=0;//答错数量
        Integer truenumber=0;//答对数量
        Integer flag1=0;
        Integer flag2=0;
        //储存正确答案
        List<Myitemresult> myitemresults_true=new ArrayList<>();
        //储存错误答案
        List<Myitemresult> myitemresults_false=new ArrayList<>();
        while (iterator.hasNext())
        {
            String key= iterator.next();
            String value=map.get(key);//例如：获取题号为1的选项内容为A
            //通过主键id获得该题目信息
            Course_exam exam=courseservice.selectbyid(key);
            //新建变量
            Myitemresult result=new Myitemresult();
            if (exam.getAnswer_true().equals(value))
            {
                //把作答的信息储存起来
                result.setExam(exam);
                result.setMyresult(value);
                myitemresults_true.add(truenumber,result);
                truenumber++;
            }
            else
            {
                //把作答的信息储存起来
                result.setExam(exam);
                result.setMyresult(value);
                myitemresults_false.add(falsenumber,result);
                falsenumber++;
            }
        }
        Integer socre=100*truenumber/(truenumber+falsenumber);
        //传送做对数据
        model.addAttribute("items_true",myitemresults_true);
        model.addAttribute("truenumber",truenumber);
        //传送做错数据
        model.addAttribute("items_false",myitemresults_false);
        model.addAttribute("falsenumber",falsenumber);
        model.addAttribute("score",socre);
        return "student/item/item_myresult";
    }


    //提交问答题习题库
    @RequestMapping("/item/exam_essay/submit")
    public String essay_submit(@RequestParam Map<String,String> map, Model model)
    {
        Set<String> set=map.keySet();//用来获取题目的id号,所以id号为String
        Iterator<String> iterator=set.iterator();//必需的
        //储存答案
        List<Myitemresult> myitemresults=new ArrayList<>();
        Integer flag=0;
        while (iterator.hasNext())
        {
            String key= iterator.next();
            String value=map.get(key);//例如：获取题号为1的选项内容为A
            //通过主键id获得该题目信息
            Course_exam exam=courseservice.selectbyid(key);
            //新建变量
            Myitemresult result=new Myitemresult();
                //把作答的信息储存起来
                result.setExam(exam);
                result.setMyresult(value);
                myitemresults.add(flag,result);
                flag++;
        }
        model.addAttribute("myitemresults",myitemresults);
        return "student/item/itemessay_myresult";
    }

    //提交章节习题并且给出正确解
    @RequestMapping("/item/exam/chapter/submit")
    public String chapter_exam_submit(@RequestParam Map<String,String> map, Model model)
    {
        Set<String> set=map.keySet();//用来获取题目的id号,所以id号为String
        Iterator<String> iterator=set.iterator();//必需的
        //储存答案
        List<Myitemresult> myitemresults=new ArrayList<>();
        Integer flag=0;
        while (iterator.hasNext())
        {
            String key= iterator.next();
            String value=map.get(key);//例如：获取题号为1的选项内容为A
            //通过主键id获得该题目信息
            Course_exam exam=courseservice.selectbyid(key);
            //新建变量
            Myitemresult result=new Myitemresult();
            //把作答的信息储存起来
            result.setExam(exam);
            result.setMyresult(value);
            myitemresults.add(flag,result);
            flag++;
        }
        model.addAttribute("myitemresults",myitemresults);
        return "student/item/item_myresult_chapter";
    }

    //管理我的单选题习题库
    @RequestMapping("/stu/item/myitem/radio/list")
    public String myitem_radio(Integer page, HttpSession session,Model model)
    {
        User user=(User)session.getAttribute("loginuser");
        //使用分页插件
        //        对第一次传值进行判断
        if (ObjectUtils.isEmpty(page)) {
            page = PaginationConstant.CURRENT_NUM;
        }
        //设置分页
        PageHelper.startPage(page, PaginationConstant.PAGE_SIZE);
        List<Course_exam> exams=itemservice.selectbymyitems(1,user.getId());
        PageInfo<Course_exam> pageInfo=new PageInfo<>(exams);
        model.addAttribute("pageinfo", pageInfo);
        return "student/item/myitem_radio";
    }
    //管理我的多选题习题库
    @RequestMapping("/stu/item/myitem/checkbox/list")
    public String myitem_checkbox(Integer page, HttpSession session,Model model)
    {
        User user=(User)session.getAttribute("loginuser");
        //使用分页插件
        //        对第一次传值进行判断
        if (ObjectUtils.isEmpty(page)) {
            page = PaginationConstant.CURRENT_NUM;
        }
        //设置分页
        PageHelper.startPage(page, PaginationConstant.PAGE_SIZE);
        List<Course_exam> exams=itemservice.selectbymyitems(2,user.getId());
        PageInfo<Course_exam> pageInfo=new PageInfo<>(exams);
        model.addAttribute("pageinfo", pageInfo);
        return "student/item/myitem_checkbox";
    }
    //管理我的多选题习题库
    @RequestMapping("/stu/item/myitem/essay/list")
    public String myitem_essay(Integer page, HttpSession session,Model model)
    {
        User user=(User)session.getAttribute("loginuser");
        //使用分页插件
        //        对第一次传值进行判断
        if (ObjectUtils.isEmpty(page)) {
            page = PaginationConstant.CURRENT_NUM;
        }
        //设置分页
        PageHelper.startPage(page, PaginationConstant.PAGE_SIZE);
        List<Course_exam> exams=itemservice.selectbymyitems(3,user.getId());
        PageInfo<Course_exam> pageInfo=new PageInfo<>(exams);
        model.addAttribute("pageinfo", pageInfo);
        return "student/item/myitem_essay";
    }

    //跳转到我的多选题添加界面
    @RequestMapping("/stu/item/myitem/checkbox/add")
    public String mycheckbox_add()
    {
        return "student/item/myitem_checkbox_add";
    }
    //跳转到我的单选题添加界面
    @RequestMapping("/stu/item/myitem/radio/add")
    public String myradio_add()
    {
        return "student/item/myitem_radio_add";
    }
    //跳转到我的问答题添加界面
    @RequestMapping("/stu/item/myitem/essay/add")
    public String myessay_add()
    {
        return "student/item/myitem_essay_add";
    }

    //完成我的习题库单选题添加
    @RequestMapping("/stu/item/myitem/radio/addsubmit")
    public String myradio_addsubmit(Course_exam exam,HttpSession session)
    {
        User user=(User)session.getAttribute("loginuser");
        //并且让这一类型的题目数量加一
        itemservice.updatebyitemtype(1);
        exam.setUser_id(user.getId());
        itemservice.insertintomyitem(exam);
        return "common/success";
    }

    //完成我的习题库多选题添加
    @RequestMapping("/stu/item/myitem/checkbox/addsubmit")
    public String mycheckbox_addsubmit(Course_exam exam,HttpSession session)
    {
        User user=(User)session.getAttribute("loginuser");
        exam.setUser_id(user.getId());
        //并且让这一类型的题目数量加一
        itemservice.updatebyitemtype(2);
        itemservice.insertintomyitem(exam);
        return "common/success";
    }
    //完成我的习题库问答题添加
    @RequestMapping("/stu/item/myitem/essay/addsubmit")
    public String myessay_addsubmit(Course_exam exam,HttpSession session)
    {
        User user=(User)session.getAttribute("loginuser");
        exam.setUser_id(user.getId());
        //并且让这一类型的题目数量加一
        itemservice.updatebyitemtype(3);
        itemservice.insertintomyitem(exam);
        return "common/success";
    }

    //修改选择题试题库前先显示出来,通过主键id显示课程试题
    @RequestMapping("/stu/item/myitem/essay/updateget")
    public String myessay_update(String id,Model model,HttpSession session)
    {
        Integer ID=Integer.parseInt(id);
        Course_exam exam=courseservice.selectbyid(id);
        model.addAttribute("exam",exam);
        return "student/item/myitem_essay_update";
    }

    //修改选择题试题库前先显示出来,通过主键id显示课程试题
    @RequestMapping("/stu/item/myitem/choose/updateget")
    public String myradio_update(String id,Model model,HttpSession session)
    {
        Integer ID=Integer.parseInt(id);
        Course_exam exam=courseservice.selectbyid(id);
        model.addAttribute("exam",exam);
        return "student/item/myitem_choose_update";
    }

    //修改选择题课程测试并且提交
    @RequestMapping("/stu/item/myitem/choose/updatesubmit")
    public String myradio_updatesubmit(Course_exam exam)
    {
        itemservice.updatebymyitemtest(exam);
        return "common/success";
    }

    //修改课程测试并且提交
    @RequestMapping("/stu/item/myitem/essay/updatesubmit")
    public String myessay_updatesubmit(Course_exam exam)
    {
        itemservice.updatebymyitemessay(exam);
        return "common/success";
    }

    //加入错题本
    @RequestMapping("/stu/item/putin_errorbook")
    @ResponseBody
    public responseresult putin_errorbook(String id,HttpSession session)
    {
        //这里有个陷阱，要修改user_id为自己的
        User user=(User)session.getAttribute("loginuser");

        //先通过主键id获得Course_exam的信息
        Course_exam exam=courseservice.selectbyid(id);
        exam.setUser_id(user.getId());
        //加入错题本
        itemservice.insertintomyerrorbook(exam);

        return responseresult.success();
    }

    //跳转到我的错题本
    @RequestMapping("/stu/item/myerror_book")
    public String lookmyerror_book(HttpSession session,Model model)
    {
        User user=(User)session.getAttribute("loginuser");
        List<Map<String,Object>> list=itemservice.selectbymyerrorbook(user.getId());
        model.addAttribute("books",list);
        return "student/item/myitem_errorbook";
    }

    //删除我的错题本
    @RequestMapping("/stu/item/myerror_book/delete")
    @ResponseBody
    public responseresult delete_myerrorbook(Integer id)
    {
        itemservice.deletebymyerrorbook(id);
        return responseresult.success();
    }



    //打印出对应的试题库中习题为word文档
    @RequestMapping("/item/export_word/{type_id}")
    public void export_word(@PathVariable("type_id")Integer type_id,HttpServletResponse response) throws Exception
    {
        List<Course_exam> essays=itemservice.selectbyitems_word(type_id);
        XWPFDocument document= new XWPFDocument();
        //添加标题
        XWPFParagraph titleParagraph = document.createParagraph();
        //设置段落居中
        titleParagraph.setAlignment(ParagraphAlignment.CENTER);

        // 标题
        XWPFRun titleParagraphRun = titleParagraph.createRun();
        // 然后把你查出的数据插入到document中去就可以了
        titleParagraphRun.setText("习题汇总");
        // 设置字体颜色
        titleParagraphRun.setColor("000000");
        // 设置字体大小
        titleParagraphRun.setFontSize(25);

        int size=essays.size();
        if (type_id==3) {
            for (int i = 0; i < size; i++) {
                Course_exam essay = essays.get(i);
                //段落
                XWPFParagraph firstParagraph = document.createParagraph();
                XWPFRun run = firstParagraph.createRun();
                run.setText("第"+i + 1 + "问:" + essay.getSubject());
                run.setColor("111111");
                run.setFontSize(20);
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + essay.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + essay.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");

            }
        }
        else {
            for (int i = 0; i < size; ) {
                Course_exam essay = essays.get(i);
                i++;
                //段落
                XWPFParagraph firstParagraph = document.createParagraph();
                XWPFRun run = firstParagraph.createRun();
                run.setText("第"+i + "问:" + essay.getSubject());
                run.setColor("111111");
                run.setFontSize(20);
                //段落
                XWPFParagraph answera_Paragraph = document.createParagraph();
                XWPFRun run_a = answera_Paragraph.createRun();
                run_a.setText("选项A:" + essay.getAnswer_a());
                run_a.setColor("000000");
                run_a.setFontSize(20);
                //段落
                XWPFParagraph answerb_Paragraph = document.createParagraph();
                XWPFRun run_b = answerb_Paragraph.createRun();
                run_b.setText("选项B:" + essay.getAnswer_b());
                run_b.setColor("000000");
                run_b.setFontSize(20);
                //段落
                XWPFParagraph answerc_Paragraph = document.createParagraph();
                XWPFRun run_c = answerc_Paragraph.createRun();
                run_c.setText("选项C:" + essay.getAnswer_c());
                run_c.setColor("000000");
                run_c.setFontSize(20);
                //段落
                XWPFParagraph answerd_Paragraph = document.createParagraph();
                XWPFRun run_d = answerd_Paragraph.createRun();
                run_d.setText("选项D:" + essay.getAnswer_d());
                run_d.setColor("000000");
                run_d.setFontSize(20);
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + essay.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + essay.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");
            }
        }
        itemservice.exportword(document, response, "习题.docx");
    }

    //打印出分章节的习题库中的习题为word文档
    @RequestMapping("/item/export_word/chapter/{chapter_id}")
    public void export_chapter_word(@PathVariable("chapter_id")Integer chapter_id,HttpServletResponse response) throws Exception
    {
        List<Course_exam> exams=itemservice.selectbyitemschapter_word(chapter_id);

        XWPFDocument document= new XWPFDocument();
        //添加标题
        XWPFParagraph titleParagraph = document.createParagraph();
        //设置段落居中
        titleParagraph.setAlignment(ParagraphAlignment.CENTER);

        // 标题
        XWPFRun titleParagraphRun = titleParagraph.createRun();
        // 然后把你查出的数据插入到document中去就可以了
        titleParagraphRun.setText("习题汇总");
        // 设置字体颜色
        titleParagraphRun.setColor("000000");
        // 设置字体大小
        titleParagraphRun.setFontSize(25);

        int size=exams.size();
        for (int i=0;i<size;)
        {
            Course_exam exam=exams.get(i);
            i++;
            //段落
            XWPFParagraph firstParagraph = document.createParagraph();
            XWPFRun run = firstParagraph.createRun();
            run.setText("第"+i + "问:" + exam.getSubject());
            run.setColor("111111");
            run.setFontSize(20);

            //判断是不是问答题
            if (exam.getType_id()==3)
            {
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + exam.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + exam.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");
            }
            else
            {
                //段落
                XWPFParagraph answera_Paragraph = document.createParagraph();
                XWPFRun run_a = answera_Paragraph.createRun();
                run_a.setText("选项A:" + exam.getAnswer_a());
                run_a.setColor("000000");
                run_a.setFontSize(20);
                //段落
                XWPFParagraph answerb_Paragraph = document.createParagraph();
                XWPFRun run_b = answerb_Paragraph.createRun();
                run_b.setText("选项B:" + exam.getAnswer_b());
                run_b.setColor("000000");
                run_b.setFontSize(20);
                //段落
                XWPFParagraph answerc_Paragraph = document.createParagraph();
                XWPFRun run_c = answerc_Paragraph.createRun();
                run_c.setText("选项C:" + exam.getAnswer_c());
                run_c.setColor("000000");
                run_c.setFontSize(20);
                //段落
                XWPFParagraph answerd_Paragraph = document.createParagraph();
                XWPFRun run_d = answerd_Paragraph.createRun();
                run_d.setText("选项D:" + exam.getAnswer_d());
                run_d.setColor("000000");
                run_d.setFontSize(20);
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + exam.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + exam.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");
            }

        }
        itemservice.exportword(document, response, "章节习题复习.docx");
    }

    //导出自己的错题本为word文档
    @RequestMapping("/stu/item/myerror_book/export_word")
    public void export_myerrorbook(HttpSession session,HttpServletResponse response)throws Exception
    {
        User user=(User)session.getAttribute("loginuser");
        List<Error_book> books=itemservice.selectbymyerrorbook_word(user.getId());

        XWPFDocument document= new XWPFDocument();
        //添加标题
        XWPFParagraph titleParagraph = document.createParagraph();
        //设置段落居中
        titleParagraph.setAlignment(ParagraphAlignment.CENTER);

        // 标题
        XWPFRun titleParagraphRun = titleParagraph.createRun();
        // 然后把你查出的数据插入到document中去就可以了
        titleParagraphRun.setText("习题汇总");
        // 设置字体颜色
        titleParagraphRun.setColor("000000");
        // 设置字体大小
        titleParagraphRun.setFontSize(25);
        int size=books.size();
        for (int i = 0; i < size; ) {
            Error_book book=books.get(i);
            i++;
            //段落
            XWPFParagraph firstParagraph = document.createParagraph();
            XWPFRun run = firstParagraph.createRun();
            run.setText("第"+i + "问:" + book.getSubject());
            run.setColor("111111");
            run.setFontSize(20);
            //判断是不是问答题
            if (book.getType_id()==3)
            {
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + book.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + book.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");
            }
            else
            {
                //段落
                XWPFParagraph answera_Paragraph = document.createParagraph();
                XWPFRun run_a = answera_Paragraph.createRun();
                run_a.setText("选项A:" + book.getAnswer_a());
                run_a.setColor("000000");
                run_a.setFontSize(20);
                //段落
                XWPFParagraph answerb_Paragraph = document.createParagraph();
                XWPFRun run_b = answerb_Paragraph.createRun();
                run_b.setText("选项B:" + book.getAnswer_b());
                run_b.setColor("000000");
                run_b.setFontSize(20);
                //段落
                XWPFParagraph answerc_Paragraph = document.createParagraph();
                XWPFRun run_c = answerc_Paragraph.createRun();
                run_c.setText("选项C:" + book.getAnswer_c());
                run_c.setColor("000000");
                run_c.setFontSize(20);
                //段落
                XWPFParagraph answerd_Paragraph = document.createParagraph();
                XWPFRun run_d = answerd_Paragraph.createRun();
                run_d.setText("选项D:" + book.getAnswer_d());
                run_d.setColor("000000");
                run_d.setFontSize(20);
                //段落
                XWPFParagraph secondParagraph = document.createParagraph();
                XWPFRun run2 = secondParagraph.createRun();
                run2.setText("答案:" + book.getAnswer_true());
                run2.setColor("000000");
                run2.setFontSize(20);
                //段落
                XWPFParagraph thirdParagraph = document.createParagraph();
                XWPFRun run3 = thirdParagraph.createRun();
                run3.setText("解析:" + book.getDescription());
                run3.setColor("000000");
                run3.setFontSize(20);
                //换行
                XWPFParagraph paragraph1 = document.createParagraph();
                XWPFRun paragraphRun1 = paragraph1.createRun();
                paragraphRun1.setText("\r");
            }
        }
        itemservice.exportword(document, response, "错题集.docx");
    }
}
